<template>
    <el-container class="home-container">
      <!-- 头部区域 -->
      <el-header>
        <div>
          <img src="../assets/heima.png" alt="">
          <span>泡泡城后台管理系统</span>
        </div>
        <span style="padding-left:1100px;">{{staffname != null ?  '欢迎用户 : '+staffname : ''}}</span>
        <font color="red"><router-link to="/login" v-if="staffname == null" style="background-color: #EAEDF1;">请登录</router-link></font>
        
        
        <el-button type="info" @click="logout">退出</el-button>
      </el-header>
      <!-- 页面主体区域 -->
      <el-container>
        <!-- 侧边栏 -->
        <el-aside :width="isCollapse ? '64px' : '200px'">
          <div class="toggle-button" @click="toggleCollapse">|||</div>
          <el-menu
            router
            background-color="#333744"
            text-color="#fff"
            active-text-color="#D8AC6B" :unique-opened="true" :collapse="isCollapse"
            :collapse-transition = "false"
            :default-active="$route.path">
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-stopwatch"></i>
                <span>数据视图</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/welcome"><i class="el-icon-menu"></i>营业金额</el-menu-item>
              </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-user-solid"></i>
                <span>系统管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/userManagement"><i class="el-icon-menu"></i>用户管理</el-menu-item>
                <el-menu-item index="/hotelPersomManagement"><i class="el-icon-menu"></i>酒店人员管理</el-menu-item>
              </el-menu-item-group>
          </el-submenu>

          <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-date"></i>
                <span>房客管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/roomreservationManagement"><i class="el-icon-menu"></i>客房预订管理</el-menu-item>
                <el-menu-item index="/ydzrzManagement"><i class="el-icon-menu"></i>预定转入住管理</el-menu-item>
                <el-menu-item index="/roomchangeManagement"><i class="el-icon-menu"></i>换房管理</el-menu-item>
                <el-menu-item index="/settleaccountsManagement"><i class="el-icon-menu"></i>结账管理</el-menu-item>
              </el-menu-item-group>
          </el-submenu>

          <el-menu-item index="/roomManagement">
            <i class="el-icon-menu"></i>
            <span slot="title" >客房管理</span>
          </el-menu-item>

          <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-s-data"></i>
                <span>基础信息管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/commodityManagement"><i class="el-icon-menu"></i>商品管理</el-menu-item>
                <el-menu-item index="/suggestManagement"><i class="el-icon-menu"></i>建议管理</el-menu-item>
              </el-menu-item-group>
          </el-submenu>

          <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-warning-outline"></i>
                <span>PA(公共区域)管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/sanitationManagement"><i class="el-icon-menu"></i>酒店卫生管理</el-menu-item>
                <el-menu-item index="/itemsadoptManagement"><i class="el-icon-menu"></i>酒店物品采购</el-menu-item>
              </el-menu-item-group>
          </el-submenu>


          <el-menu-item index="/customerservice1">
            <i class="el-icon-menu"></i>
            <span slot="title" >客服管理</span>
          </el-menu-item>

         
          </el-menu>
        </el-aside>
        <!-- 右 -->
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
</template>

<script>
export default {
  data() {
    return {
      //是否折叠
      isCollapse : false,
      //激活的地址
      activePath : '',
      staffname : ''
    }
  },
  created() {
    this.activePath = window.sessionStorage.getItem('activePath')
    var staffname = sessionStorage.getItem('staffid')
    this.staffname = staffname
  },
  methods: {
    logout() {
      sessionStorage.removeItem('staffid')
      this.$router.push('/login')
    },
    //点击按钮 切换菜单的折叠 与 展开
    //效果属性
    toggleCollapse(){
      this.isCollapse = !this.isCollapse
    },
    saveNavState(activePath){
      window.sessionStorage.setItem('activePath',activePath)
      this.activePath = activePath
    }
  }
}
</script>

<style lang="less" scoped>
.home-container{
  height: 100%;
}
.el-header{
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #fff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    span{
      margin-left: 15px;
    }
  }
}
.el-aside{
  background-color: #333744;
  .el-menu{
    border-right : none
  }
}
.el-main{
  background-color: #EAEDF1;
}
.iconfont {
  margin-right: 10px;
}
.toggle-button{
  background-color: #4A5064;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>
